<?php
include "conn.php";//引入数据库连接

//1.将注册数据提交到数据库
if(isset($_POST['submit'])){//判断是否点击了submit按钮
    //获取表单的值
    $telphone = $_POST['tel'];
    $password = sha1($_POST['password']);
    $tel = $_POST['tel'];
    $conn->query("insert users values(null,'$telphone','$password',NOW())");
    //跳转到登录页面
    header('location:http://10.31.157.18/changhong/src/login.html');
}


//2.手机号码重名检测
if(isset($_POST['telphone'])){
    $telphone = $_POST['telphone'];
    $result = $conn->query("select * from users where telphone='$telphone'");//检测当前的手机号是否存在。
    if($result->fetch_assoc()){
        echo true;
    }else{
        echo false;
    }
}